package org.yoyo.classroom.mapper;


import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.security.core.parameters.P;
import org.yoyo.classroom.domain.po.BookingRule;
import org.yoyo.classroom.domain.po.StudyRoom;
import org.yoyo.classroom.domain.po.StudyRoomCategory;
import org.yoyo.classroom.domain.po.StudyRoomFacility;
import org.yoyo.classroom.domain.vo.AvailableBookingTimeVO;
import org.yoyo.classroom.domain.vo.SeatWithBookingStatusVO;
import org.yoyo.classroom.domain.vo.StudyRoomDetailVO;
import org.yoyo.classroom.domain.vo.StudyRoomReviewSummary;

import java.util.List;

/**
 * 自习室Mapper接口
 */
@Mapper
public interface StudyRoomMapper {

    /**
     * 根据ID查询自习室
     *
     * @param id 自习室ID
     * @return 自习室对象
     */
    StudyRoom selectById(@Param("id") Long id);

    /**
     * 查询所有自习室
     *
     * @return 自习室列表
     */
    List<StudyRoom> selectAll();

    /**
     * 插入自习室
     *
     * @param studyRoom 自习室对象
     * @return 影响的行数
     */
    int insert(StudyRoom studyRoom);

    /**
     * 更新自习室
     *
     * @param studyRoom 自习室对象
     * @return 影响的行数
     */
    int update(StudyRoom studyRoom);

    /**
     * 删除自习室（逻辑删除）
     *
     * @param id 自习室ID
     * @return 影响的行数
     */
    int delete(@Param("id") Long id);

    //查询热门自习室（前三）
    List<StudyRoomReviewSummary> getTopRatedStudyRooms();

    //自习室详情页
    StudyRoomDetailVO getStudyRoomDetail(@Param("roomId") Integer roomId);

    List<StudyRoom> getStudyRoomsByFilters(@Param("type") Integer type, @Param("facilities") String facilities, @Param("sort") String sort);


    List<StudyRoomCategory> selectAllType();

    List<StudyRoomFacility> selectAllStudyRoomFacilities();

    BookingRule getBookingRuleByRoomId(@Param("roomId") Long roomId);

    List<SeatWithBookingStatusVO>getSeatsWithBookingStatus(@Param("roomId") Long roomId);

    //获取座位未来的时刻信息
    List<AvailableBookingTimeVO> getAvailableBookingTimes(@Param("roomId") Long roomId, @Param("seatId") Long seatId);

    BookingRule getRoomRuleById(@Param("roomId") Long roomId);
}
